# -*- encoding: utf-8 -*-
"""
File Name: subscription_info_handle
Description:
Author : 'lirui'
date: 11/1/2024
Contact: marjey_lee@163.com
Change Activity:
11/1/2024:
"""
from projects.monitoring.alarms_manager.services.current_alarms_manager import CurrentAlarmsManager
from projects.monitoring.alarms_manager.utils.handle_subscribe_info_util import format_alarms


def handle_subscribe_info(content):
    """
    handle_subscribe_info
    Args:
        content:

    Returns:

    """
    # try:
    format_data = format_alarms(content)  # original alarms.
    if format_data is None:
        return
    _handle(format_data)


# except Exception as e:
#     ll.get_logger().error(e)


def _handle(format_data):
    subscribe_type = format_data['publish_channel']
    alarms = format_data['alarms']
    current_alarm_manager = CurrentAlarmsManager(subscribe_type=subscribe_type, subscribe_alarms=alarms)
    current_alarm_manager.handle()
